package io.renren.modules.department.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.department.entity.AccountingDepartInforEntity;
import io.renren.modules.department.service.AccountingDepartInforService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 人事部成员信息表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2021-12-31 10:59:45
 */
@RestController
@RequestMapping("department/accountingdepartinfor")
public class AccountingDepartInforController {
    @Autowired
    private AccountingDepartInforService accountingDepartInforService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("department:accountingdepartinfor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = accountingDepartInforService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{accountingDepartId}")
    @RequiresPermissions("department:accountingdepartinfor:info")
    public R info(@PathVariable("accountingDepartId") Long accountingDepartId){
        AccountingDepartInforEntity accountingDepartInfor = accountingDepartInforService.getById(accountingDepartId);

        return R.ok().put("accountingDepartInfor", accountingDepartInfor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("department:accountingdepartinfor:save")
    public R save(@RequestBody AccountingDepartInforEntity accountingDepartInfor){
        accountingDepartInforService.save(accountingDepartInfor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("department:accountingdepartinfor:update")
    public R update(@RequestBody AccountingDepartInforEntity accountingDepartInfor){
        ValidatorUtils.validateEntity(accountingDepartInfor);
        accountingDepartInforService.updateById(accountingDepartInfor);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("department:accountingdepartinfor:delete")
    public R delete(@RequestBody Long[] accountingDepartIds){
        accountingDepartInforService.removeByIds(Arrays.asList(accountingDepartIds));

        return R.ok();
    }

}
